/**
 * Created by baiguiren on 1/23/17.
 */

let async = require('async');

// Pretend this is some complicated async factory
let createUser = function (id, callback) {
  callback(null, {
    id: 'user' + id
  });
};

//generate 5 users
async.times(5, function (n, next) {
  createUser(n, function (err, user) {
    next(err, user);
  });
}, function (err, users) {
  // we should now have 5 users
  console.log(users);
});

